package com.example.a19859218698_homework2;

import android.os.Bundle;
import android.view.Gravity;
import android.widget.LinearLayout;

import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;

public class Uc1Activity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_uc1);

        LinearLayout demoLayout = findViewById(R.id.demo_layout);

        // 水平布局
        findViewById(R.id.btn_horizontal).setOnClickListener(v -> {
            demoLayout.setOrientation(LinearLayout.HORIZONTAL);
            demoLayout.setGravity(Gravity.CENTER);
        });

        // 垂直布局
        findViewById(R.id.btn_vertical).setOnClickListener(v -> {
            demoLayout.setOrientation(LinearLayout.VERTICAL);
            demoLayout.setGravity(Gravity.CENTER);
        });

        // 靠左布局
        findViewById(R.id.btn_left).setOnClickListener(v -> {
            demoLayout.setOrientation(LinearLayout.HORIZONTAL);
            demoLayout.setGravity(Gravity.START);
        });

        // 返回
        findViewById(R.id.btn_back).setOnClickListener(v -> finish());

    }
}